<?php

/**
 * Fichas form base class.
 *
 * @method Fichas getObject() Returns the current form's model object
 *
 * @package    sbweb3
 * @subpackage form
 * @author     Pablo Andrés Díaz
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseFichasForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'idficha'           => new sfWidgetFormInputHidden(),
      'ficha_no'          => new sfWidgetFormInputText(),
      'biblioteca'        => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Biblioteca'), 'add_empty' => true)),
      'etiquetas_marc'    => new sfWidgetFormTextarea(),
      'titulo'            => new sfWidgetFormTextarea(),
      'autor'             => new sfWidgetFormTextarea(),
      'clasificacion'     => new sfWidgetFormInputText(),
      'isbn'              => new sfWidgetFormInputText(),
      'fecha_publicacion' => new sfWidgetFormInputText(),
      'tipo_material'     => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('TipoMaterial'), 'add_empty' => true)),
      'created_at'        => new sfWidgetFormDateTime(),
      'updated_at'        => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'idficha'           => new sfValidatorChoice(array('choices' => array($this->getObject()->get('idficha')), 'empty_value' => $this->getObject()->get('idficha'), 'required' => false)),
      'ficha_no'          => new sfValidatorInteger(array('required' => false)),
      'biblioteca'        => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Biblioteca'), 'required' => false)),
      'etiquetas_marc'    => new sfValidatorString(array('required' => false)),
      'titulo'            => new sfValidatorString(array('required' => false)),
      'autor'             => new sfValidatorString(array('required' => false)),
      'clasificacion'     => new sfValidatorString(array('max_length' => 50, 'required' => false)),
      'isbn'              => new sfValidatorString(array('max_length' => 50, 'required' => false)),
      'fecha_publicacion' => new sfValidatorString(array('max_length' => 20, 'required' => false)),
      'tipo_material'     => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('TipoMaterial'), 'required' => false)),
      'created_at'        => new sfValidatorDateTime(),
      'updated_at'        => new sfValidatorDateTime(),
    ));

    $this->widgetSchema->setNameFormat('fichas[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Fichas';
  }

}
